import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Objects;

/**
 * User: yian
 * Date: 2018/6/10
 */
public class test {
    public static void main(String[] args) throws SQLException {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                new String[]{"aplication.xml"});
        context.start();
        // obtain proxy object for remote invocation
        DataSource dataSource = (DataSource) context.getBean("dataSource");
        // execute remote invocation
        if (Objects.nonNull(dataSource)) {
            Connection connection = dataSource.getConnection();
            System.out.println(connection.toString());
        }
    }
}
